import {BarChartOutlined, HomeOutlined} from "@ant-design/icons";
import {ReactElement} from "react";
import {IndexLayout} from "@/layout";
import {IndexPage} from "@/pages/index";
import {RankingPage} from "@/pages/ranking";
import {LoginPage} from "@/pages/login";
import {BookInfo} from "@/pages/bookInfo";
import {UserProfile} from "@/pages/user";

export interface RouteOption {
    path: string,
    label?: string,
    element: ReactElement,
    children?: RouteOption[]
    icon?: ReactElement,
    redirect?: string

}

export const NavList: RouteOption[] = [
    {
        path: "index",
        label: "首页",
        element: <IndexPage/>,
        icon: <HomeOutlined/>
    },
    {
        path: "ranking",
        label: "排行榜",
        element: <RankingPage/>,
        icon: <BarChartOutlined/>
    }
]
export const MyRouterConfig: RouteOption[] = [
    {
        path: "/*",
        element: <IndexLayout/>,
        children: [
            ...NavList,
            {
                path: "bookInfo",
                element: <BookInfo/>,
            },
            {
                path: "userProfile",
                element: <UserProfile/>,
            }
        ],
    },
    {
        path: "/login",
        element: <LoginPage/>,
    }
]
//
// function initRouterConfig(router: RouteOption[] = MyRouterConfig, path: string | undefined = "") {
//     return router.map(item => {
//         item.path = path === "/" ? item.path : (path + item.path)
//         if (item.children){
//             item.children = initRouterConfig(item.children,item.path)
//         }
//         return item
//     })
//
// }
// const RouterConfig = initRouterConfig()
//
// export default RouterConfig
